package enums;

/**回执状态*/
public enum DeliveryStatus {
	/**短消息转发成功*/
	DELIVRD(0, "DELIVRD"),
	/**短消息超过有效期*/
	EXPIRED(1, "EXPIRED"),
	/**短消息已经被删除*/
	DELETED(2, "DELETED"),
	/**短消息是不可转发的 { 用户长时间关机或不在服务区 }*/
	UNDELIV(3, "UNDELIV"),
	/**短消息被接收*/
	ACCEPTD(4, "ACCEPTD"),
	/**未知短消息状态*/
	UNKNOWN(5, "UNKNOWN"),
	/**短消息被拒绝(为保持与SMPP兼容，保留)*/
	REJECTD(6, "REJECTD"),
	/**黑名单*/
	BLACKLIST(7, "BLACKLIST"),
	/**运营商网关异常*/
	SPERROR(8, "SPERROR"),
	/**运营商关键字拦截*/
	SPAM(9, "SPAM"),
	/**终端信号异常*/
	NOSIGNAL(10, "NOSIGNAL"),
	/**空号*/
	UNOCCUPIED(11, "UNOCCUPIED"),
	/**关机/停机*/
	OFFLINE(12, "OFFLINE"),
	/**暂停服务*/
	PAUSE(13, "PAUSE"),
	/**非法号码或者号码不支持接收短信*/
	UNSUPPORTED(14, "UNSUPPORTED"),
	/**因规则或数量被限制下发*/
	LIMITED(15, "LIMITED"),
	/**携号转网异常*/
	NUMBERTRANSFER(16, "NUMBERTRANSFER"),
	/**运营商拦截*/
	INTERCEPT(17, "INTERCEPT"),
	/**发送超时*/
	TimeOut(18, "TimeOut"),
	/**余额不足*/
	Balance(19, "Balance"),
	/**未发送到网关*/
	UnSent(20, "UnSent"),
	/**重复发送*/
	REPEATD(21, "REPEATD");
	
	DeliveryStatus(int code, String value) {
		this.code = code;
		this.value = value;
	}
	
	private String value;
	private int code;
	
	public String getValue() {
        return value;
    }

    public int getCode() {
        return code;
    }
    
    public static DeliveryStatus codeOf(int code) {
    	System.out.println("code = " + code);
		for(DeliveryStatus deliveryStatus : values()) {
			if(deliveryStatus.getCode() == code) {
				return deliveryStatus;
			}
		}
		throw new RuntimeException("code = " + code + " 没有找到对应的枚举");
	}
}
